home *** CD-ROM | disk | FTP | other *** search
/ PC Open 97 / PC Open 97 CD2.bin / Demo / FileMaker / Data1.cab / fmi_iwp.js < prev    next >
Encoding:
JavaScript  |  2004-02-10  |  41.6 KB  |  1,270 lines

  1. /*===================================================================================
  2.  
  3.   copyright: (C) Copyright 2003-2004 Filemaker, Inc. All Rights Reserved
  4.   
  5.   =================================================================================*/
  6.  
  7. function IWPObj()
  8. {
  9.     /***** utility methods *****************************************/
  10.     
  11.     this.addOrReplaceTextNode = function( doc, objID, str, replace )
  12.     {
  13.         if( doc != null && objID != null && str != null )
  14.         {
  15.             var obj = doc.getElementById( objID );
  16.             if( obj != null )
  17.             {
  18.                 var txt = doc.createTextNode( str );
  19.                 if( replace != null )
  20.                 {
  21.                     if( obj.hasChildNodes() )
  22.                     {
  23.                         if( obj.childNodes.length > replace )
  24.                         {
  25.                             var node = obj.childNodes.item( replace );
  26.                             obj.replaceChild( txt, node );
  27.                         }
  28.                         else
  29.                             obj.appendChild( txt );
  30.                     }
  31.                     else
  32.                         obj.appendChild( txt );
  33.                 }
  34.                 else
  35.                     obj.appendChild( txt );
  36.             }
  37.         }
  38.     }
  39.     
  40.     this.cgiPath = function()
  41.     {
  42.         bFrame = this.bodyFrame;
  43.         if( bFrame != null && bFrame.iwpinfo != null )
  44.         {
  45.             var path = bFrame.iwpinfo.cgipath;
  46.             if( this.debugurl && bFrame.iwpinfo.debug != null  )
  47.             {
  48.                 path = bFrame.iwpinfo.debug;
  49.             }
  50.             return path;
  51.         }
  52.         else
  53.             return null;
  54.     }
  55.     
  56.     this.checkForSafari10 = function()
  57.     {
  58.         var result = false;
  59.         var targ = "AppleWebKit";
  60.         var av = navigator.appVersion;
  61.         var start = av.indexOf(targ);
  62.         if( start > -1 )
  63.         {
  64.             start = start + targ.length + 1;
  65.             var end = av.indexOf(" ", start) - start;
  66.             vers = parseFloat( av.substr( start, end ) );
  67.             if( vers < 103 )
  68.                 result = true;
  69.         }
  70.         return result;
  71.     }
  72.     
  73.     this.executebuttonscript = function( index, parentrecid, childrecid )
  74.     {
  75.         if( index != null )
  76.             if ( parentrecid != null && childrecid != null )
  77.                 this.submitAndContinue( [{target: "-type", n: "-index", v: index},
  78.                     {target: "-omitstate", n: "-recid", v: parentrecid},
  79.                     {target: null, n: "-relatedrecid", v: childrecid},
  80.                     {target: "-submitclose", n: "-buttonscript", v: ""}] );
  81.             else
  82.             //    if there is no recid execute the buttonscript without specifying it
  83.                 this.submitAndContinue( [{target: "-type", n: "-index", v: index},
  84.                     {target: "-submitclose", n: "-buttonscript", v: ""}] );
  85.     }
  86.     
  87.     this.objectEnabled = function( obj )
  88.     {
  89.         if( obj != null && obj.id != null && this.objstate != null )
  90.         {
  91.             var state = this.objstate[obj.id]
  92.             if( state != null )
  93.                 return ! state;
  94.         }
  95.         return false;
  96.     }
  97.     
  98.     this.openUrlWindows = function( args )
  99.     {
  100.         if( args != null && args.length )
  101.         {
  102.             for( var i in args )
  103.                 window.open( args[i] );
  104.         }
  105.     }
  106.     
  107.     this.setAltAttributes = function( doc, objID, str )
  108.     {
  109.         if( doc != null && objID != null && str != null )
  110.         {
  111.             var obj = doc.getElementById( objID );
  112.             if( obj != null )
  113.             {
  114.                 obj.setAttribute( "title", str );
  115.                 obj.setAttribute( "alt", str );
  116.             }
  117.         }
  118.     }
  119.     
  120.     this.setAttribute = function( doc, objID, att, val )
  121.     {
  122.         if( doc != null && objID != null && att != null && val != null )
  123.         {
  124.             var obj = doc.getElementById( objID );
  125.             if( obj != null )
  126.                 obj.setAttribute( att, val );
  127.         }
  128.     }
  129.     
  130.     this.setImgButtonState = function( doc, objID, img, disabled )
  131.     {
  132.         if( doc != null && objID != null && img != null )
  133.         {
  134.             var url = this.imgPath + img;
  135.             if( disabled == null ) disabled = false;
  136.             if( disabled )
  137.                 url += "_x.gif";
  138.             else
  139.                 url += "_n.gif";
  140.             var obj = doc.getElementById( objID );
  141.             if( obj != null )
  142.                 obj.src = url;
  143.             this.objstate[objID] = disabled;
  144.         }
  145.     }
  146.     
  147.     this.setObjVisibility = function( doc, objID, visible )
  148.     {
  149.         if( doc != null && objID != null && visible != null )
  150.         {
  151.             var obj = doc.getElementById( objID );
  152.             if( obj != null )
  153.             {
  154.                 if( visible )
  155.                     obj.style.visibility = "visible";
  156.                 else
  157.                     obj.style.visibility = "hidden";
  158.             }
  159.         }
  160.     }
  161.  
  162.     this.setTop = function( doc, objID, pos )
  163.     {
  164.         if( doc != null && objID != null && pos != null )
  165.         {
  166.             var obj = doc.getElementById( objID );
  167.             if( obj != null && obj.style != null )
  168.                 obj.style.top = parseFloat(pos) + "px";
  169.         }
  170.     }
  171.     
  172.     this.setupRollover = function( doc, objID, name )
  173.     {
  174.         if( doc != null && objID != null && name != null )
  175.         {
  176.             var obj = doc.getElementById( objID );
  177.             if( obj != null )
  178.             {
  179.                 var baseUrl = this.imgPath + name;
  180.                 var norm = new Image();
  181.                 var url = baseUrl + "_n.gif";
  182.                 norm.src = url;
  183.                 var roll = new Image();
  184.                 url = baseUrl + "_o.gif";
  185.                 roll.src = url;
  186.                 var down = new Image();
  187.                 url = baseUrl + "_d.gif";
  188.                 down.src = url;
  189.                 obj.images = new Array(norm, roll, down);
  190.                 this.objstate[objID] = false;
  191.             }
  192.         }
  193.     }
  194.     
  195.     this.setValue = function( doc, objID, val )
  196.     {
  197.         if( doc != null && objID != null && val != null )
  198.         {
  199.             var obj = doc.getElementById( objID );
  200.             if( obj != null )
  201.             {
  202.                 try
  203.                 {
  204.                     obj.value = val;
  205.                 }
  206.                 catch(e){}
  207.             }
  208.         }
  209.     }
  210.  
  211.     this.showToolBox = function( show )
  212.     {
  213.         var sFrame = this.statusFrame;
  214.         if( sFrame != null && sFrame.document != null )
  215.         {
  216.             var sDoc = sFrame.document;
  217.             var toolBox = sDoc.getElementById( "toolBox2" );
  218.             var moveBox = sDoc.getElementById( "moveBox" );
  219.             if( toolBox != null && moveBox != null && this.strings != null )
  220.             {
  221.                 if( show )
  222.                 {
  223.                     toolBox.style.visibility = "visible";
  224.                     this.positions.visible = true;
  225.                     if( this.positions.oldTop == null )
  226.                         this.positions.oldTop = moveBox.style.top;
  227.                     if( this.positions.newTop == null )
  228.                         this.positions.newTop = ( parseFloat(moveBox.style.top) + parseFloat(toolBox.style.height) ) + "px";
  229.                     moveBox.style.top = this.positions.newTop;
  230.                     var btn = sDoc.getElementById( "downButton" );
  231.                     this.swapImage( btn, 0 );
  232.                     this.setObjVisibility( sDoc, "downBox", false );
  233.                 }
  234.                 else
  235.                 {
  236.                     toolBox.style.visibility = "hidden";
  237.                     this.positions.visible = false;
  238.                     moveBox.style.top = this.positions.oldTop;
  239.                     var btn = sDoc.getElementById( "upButton" );
  240.                     this.swapImage( btn, 0 );
  241.                     this.setObjVisibility( sDoc, "downBox", true );
  242.                 }
  243.             }
  244.         }
  245.     }
  246.  
  247.     this.submitAndContinue = function( args, target )
  248.     {
  249.         var bFrame = this.bodyFrame;
  250.         var frm = null;
  251.         var url = this.cgiPath();
  252.         if( bFrame != null && bFrame.document != null )
  253.             frm = bFrame.document.getElementById( "iwpform" );            
  254.         if( frm != null )
  255.         {
  256.             if( args != null )
  257.             {
  258.                 for ( var i in args )
  259.                 {
  260.                     if( args[i].target != null  )
  261.                     {
  262.                         var obj = frm.elements[ args[i].target ];
  263.                         if( obj != null )
  264.                         {
  265.                             obj.setAttribute("name", args[i].n);
  266.                             obj.setAttribute("value", args[i].v);
  267.                         }
  268.                     }
  269.                 }
  270.             }
  271.             if( target != null )
  272.                 frm.setAttribute("target", target);
  273.             if( this.debugurl )
  274.                 frm.setAttribute("action", url);
  275.             frm.submit();
  276.         }
  277.         else if( args != null && url != null )
  278.         {
  279.             var end = args.length - 1;
  280.             for ( var i in args )
  281.             {
  282.                 url += args[i].n + "=" + escape(args[i].v);
  283.                 if( i < end )
  284.                     url += "&";
  285.             }
  286.             if( target != null )
  287.             {
  288.                 if( target == "_top" )
  289.                     window.location = url;
  290.                 else
  291.                     window.open( url, target, "location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes" );
  292.             }
  293.             else if( bFrame != null )
  294.                 bFrame.location = url;
  295.         }
  296.     }
  297.     
  298.     this.submitFindRequest = function( args )
  299.     {
  300.         var sFrame = this.statusFrame;
  301.         if( args != null && sFrame != null && sFrame.document != null )
  302.         {
  303.             var omit = sFrame.document.getElementById( "omitCheckbox" );
  304.             if( omit != null )
  305.             {
  306.                 var flag = "false";
  307.                 if( omit.checked == true )
  308.                     flag = "true";
  309.                 args[args.length] = {target: "-omitstate", n: "-omitstate", v: flag};
  310.                 this.submitAndContinue( args );
  311.             }
  312.         }
  313.     }
  314.     
  315.     this.swapImage = function( obj, index )
  316.     {
  317.         if( obj != null && obj.images != null && index > -1 && index < 4 && this.objectEnabled( obj ) )
  318.         {
  319.             var img = obj.images[index].src;
  320.             if( img != null )
  321.                 obj.src = img;
  322.         }
  323.     }
  324.     
  325.     this.toggleStatusArea = function( obj )
  326.     {
  327.         if( obj != null && this.objectEnabled( obj ) )
  328.         {
  329.             var status = this.statusVisible;
  330.             var action = "-";
  331.             if( status )
  332.                 action += "hidestatus";
  333.             else
  334.                 action += "showstatus";
  335.             this.submitAndContinue( [{target: "-submitclose", n: action, v: ""}], "_top" );
  336.         }
  337.     }
  338.     
  339.     this.toggleToolBox = function()
  340.     {
  341.         var sFrame = this.statusFrame;
  342.         if( sFrame != null && sFrame.document != null )
  343.         {
  344.             var sDoc = sFrame.document;
  345.             var toolBox = sDoc.getElementById( "toolBox2" );
  346.             var show = true;
  347.             if( toolBox != null )
  348.             {
  349.                 if( toolBox.style.visibility == "visible" )
  350.                     show = false;
  351.                 this.showToolBox( show );
  352.             }
  353.         }
  354.     }
  355.  
  356.     this.unimplemented = function()
  357.     {
  358.         alert("Unimplemented!");
  359.     }
  360.     
  361.     /***** setup methods *****************************************/
  362.     
  363.     this.setupControlFrame = function( win, info )
  364.     {
  365.         this.controlFrame = win;
  366.         var cFrame = this.controlFrame;
  367.         if( this.strings != null && cFrame != null && cFrame.document != null )
  368.         {
  369.             var strs = this.strings;
  370.             var status = this.statusVisible;
  371.             var c = cFrame.document;
  372.             if( status )
  373.             {
  374.                 this.setAltAttributes( c, "toggleButton", strs.cont_hlp_collapse );
  375.                 this.setupRollover( c, "toggleButton", "collapse" );
  376.             }
  377.             else
  378.             {
  379.                 this.setAltAttributes( c, "toggleButton", strs.cont_hlp_expand );
  380.                 this.setupRollover( c, "toggleButton", "expand" );
  381.             }
  382.             var hide = true;
  383.             var bFrame = this.bodyFrame;
  384.             if( bFrame != null && bFrame.iwpinfo != null )
  385.                 hide = bFrame.iwpinfo.locked;
  386.             this.setImgButtonState( c, "toggleButton", "collapse", hide );
  387.             this.swapImage( c.getElementById( "toggleButton" ), 0 );
  388.             if( info == null && this.bodyFrame != null )
  389.                 info = this.bodyFrame.iwpinfo;
  390.             if( info != null && info.locked )
  391.                 this.setImgButtonState( c, "toggleButton", "collapse", true );
  392.         }
  393.     }
  394.  
  395.     this.setupStatusFrame = function( frame )
  396.     {
  397.         if( frame != null && this.strings != null )
  398.         {
  399.             this.statusFrame = frame;
  400.             var strs = this.strings;
  401.             var sFrame = this.statusFrame;
  402.             if( sFrame.document != null )
  403.             {
  404.                 var s = sFrame.document;
  405.                 this.addOrReplaceTextNode( s, "modeBrowseBox", strs.stat_mode_browse );
  406.                 this.addOrReplaceTextNode( s, "modeFindBox", strs.stat_mode_find );
  407.                 this.addOrReplaceTextNode( s, "modeEditBox", strs.stat_mode_edit );
  408.                 this.addOrReplaceTextNode( s, "viewttlBox", strs.stat_lbl_viewas );
  409.                 this.addOrReplaceTextNode( s, "layttlBox", strs.stat_lbl_lay );
  410.                 this.addOrReplaceTextNode( s, "eprecordTxt", strs.stat_lbl_rec );
  411.                 this.addOrReplaceTextNode( s, "epfoundTxt", strs.stat_lbl_found );
  412.                 this.addOrReplaceTextNode( s, "eptotalTxt", strs.stat_lbl_total );
  413.                 this.addOrReplaceTextNode( s, "recordSpan", strs.stat_lbl_rec );
  414.                 this.addOrReplaceTextNode( s, "requestSpan", strs.stat_lbl_req );
  415.                 this.addOrReplaceTextNode( s, "requestsTxt", strs.stat_lbl_totreq );
  416.                 this.addOrReplaceTextNode( s, "currecBox", strs.stat_lbl_currec );
  417.                 this.addOrReplaceTextNode( s, "totalTxt", strs.stat_lbl_total );
  418.                 this.addOrReplaceTextNode( s, "foundTxt", strs.stat_lbl_found );
  419.                 this.addOrReplaceTextNode( s, "scriptSpan", strs.stat_lbl_script );
  420.                 this.addOrReplaceTextNode( s, "omitTxtBox", strs.stat_lbl_omit );
  421.                 this.setAltAttributes( s, "homeButton", strs.stat_hlp_home );
  422.                 this.setAltAttributes( s, "browseButton", strs.stat_hlp_browse );
  423.                 this.setAltAttributes( s, "findButton", strs.stat_hlp_find );
  424.                 this.setAltAttributes( s, "helpButton", strs.stat_hlp_help );
  425.                 this.setAltAttributes( s, "resetButton", strs.stat_hlp_undoedit );
  426.                 this.setAltAttributes( s, "resetFindButton", strs.stat_hlp_undofind );
  427.                 this.setAltAttributes( s, "newButton", strs.stat_hlp_new );
  428.                 this.setAltAttributes( s, "editButton", strs.stat_hlp_edit );
  429.                 this.setAltAttributes( s, "noeditButton", strs.stat_hlp_noedit );
  430.                 this.setAltAttributes( s, "dupButton", strs.stat_hlp_dup );
  431.                 this.setAltAttributes( s, "deleteButton", strs.stat_hlp_del );
  432.                 this.setAltAttributes( s, "sortButton", strs.stat_hlp_sort );
  433.                 this.setAltAttributes( s, "showallButton", strs.stat_hlp_all );
  434.                 this.setAltAttributes( s, "downButton", strs.stat_hlp_show );
  435.                 this.setAltAttributes( s, "upButton", strs.stat_hlp_hide );
  436.                 this.setAltAttributes( s, "omitButton", strs.stat_hlp_omit );
  437.                 this.setAltAttributes( s, "omitmultiButton", strs.stat_hlp_omitmulti );
  438.                 this.setAltAttributes( s, "showomitButton", strs.stat_hlp_showomit );
  439.                 this.setAltAttributes( s, "goRecButton", strs.stat_hlp_go );
  440.                 this.setAltAttributes( s, "goReqButton", strs.stat_hlp_goreq );
  441.                 this.setAltAttributes( s, "reqnumField", strs.stat_hlp_cureq );
  442.                 this.setAltAttributes( s, "recnumField", strs.stat_hlp_curec );
  443.                 this.setAltAttributes( s, "prevButton", strs.stat_hlp_prev );
  444.                 this.setAltAttributes( s, "prevFindButton", strs.stat_hlp_prevreq );
  445.                 this.setAltAttributes( s, "prevMultiButton", strs.stat_hlp_prevmulti );
  446.                 this.setAltAttributes( s, "nextButton", strs.stat_hlp_next );
  447.                 this.setAltAttributes( s, "nextFindButton", strs.stat_hlp_nextreq );
  448.                 this.setAltAttributes( s, "nextMultiButton", strs.stat_hlp_nextmulti );
  449.                 this.setAltAttributes( s, "refindButton", strs.stat_hlp_refind );
  450.                 this.setAltAttributes( s, "newReqButton", strs.stat_hlp_newreq );
  451.                 this.setAltAttributes( s, "dupReqButton", strs.stat_hlp_dupreq );
  452.                 this.setAltAttributes( s, "delReqButton", strs.stat_hlp_delreq );
  453.                 this.setAltAttributes( s, "showallButton2", strs.stat_hlp_all );
  454.                 this.setAltAttributes( s, "submitButton", strs.stat_hlp_submit );
  455.                 this.setAltAttributes( s, "cancelButton", strs.stat_hlp_cancel );
  456.                 this.setupRollover( s, "homeButton", "home" + ( this.isEnglish ? "" : "2" ) );
  457.                 this.setupRollover( s, "browseButton", "browse" + ( this.isEnglish ? "" : "2" ) );
  458.                 this.setupRollover( s, "findButton", "find" + ( this.isEnglish ? "" : "2" ) );
  459.                 this.setupRollover( s, "helpButton", "help" );
  460.                 this.setupRollover( s, "resetButton", "undo" );
  461.                 this.setupRollover( s, "resetFindButton", "undo" );
  462.                 this.setupRollover( s, "newButton", "new" );
  463.                 this.setupRollover( s, "editButton", "edit" );
  464.                 this.setupRollover( s, "noeditButton", "noedit" );
  465.                 this.setupRollover( s, "dupButton", "dup" );
  466.                 this.setupRollover( s, "deleteButton", "delete" );
  467.                 this.setupRollover( s, "sortButton", "sort" );
  468.                 this.setupRollover( s, "showallButton", "showall" );
  469.                 this.setupRollover( s, "downButton", "down" );
  470.                 this.setupRollover( s, "upButton", "up" );
  471.                 this.setupRollover( s, "newReqButton", "newreq" );
  472.                 this.setupRollover( s, "dupReqButton", "dupreq" );
  473.                 this.setupRollover( s, "delReqButton", "delreq" );
  474.                 this.setupRollover( s, "showallButton2", "showall" );
  475.                 this.setupRollover( s, "omitButton", "omit" );
  476.                 this.setupRollover( s, "omitmultiButton", "omitmulti" );
  477.                 this.setupRollover( s, "showomitButton", "showomit" );
  478.                 this.setupRollover( s, "goRecButton", "go" );
  479.                 this.setupRollover( s, "goReqButton", "go" );
  480.                 this.setupRollover( s, "prevButton", "previous" );
  481.                 this.setupRollover( s, "prevFindButton", "previous" );
  482.                 this.setupRollover( s, "prevMultiButton", "previous" );
  483.                 this.setupRollover( s, "nextButton", "next" );
  484.                 this.setupRollover( s, "nextFindButton", "next" );
  485.                 this.setupRollover( s, "nextMultiButton", "next" );
  486.                 this.setupRollover( s, "refindButton", "refind" );
  487.                 this.setValue( s, "submitButton", strs.stat_btn_submit );
  488.                 this.setValue( s, "submitButton", strs.stat_btn_submit );
  489.                 this.setValue( s, "cancelButton", strs.stat_btn_cancel );
  490.                 this.setValue( s, "contScriptButton", strs.stat_btn_cont );
  491.                 this.setValue( s, "cancelScriptButton", strs.stat_btn_cancel );
  492.                 this.setValue( s, "logoutButton", strs.stat_btn_logout );
  493.                 this.setValue( s, "performFindButton", strs.stat_lbl_pfind );
  494.                 this.setValue( s, "extendFindButton", strs.stat_lbl_efind );
  495.                 this.setValue( s, "constrainFindButton", strs.stat_lbl_cfind );
  496.  
  497.                 var obj = s.getElementById("symbolpopup");
  498.                 if( obj != null && obj.options != null )
  499.                 {
  500.                     obj.options[0] = new sFrame.Option( strs.stat_pop_syms );
  501.                     obj.options[1] = new sFrame.Option( "< " + strs.stat_pop_lt, "<" );
  502.                     obj.options[2] = new sFrame.Option( "<= " + strs.stat_pop_lte, "<=" );
  503.                     obj.options[3] = new sFrame.Option( "> " + strs.stat_pop_gt, ">" );
  504.                     obj.options[4] = new sFrame.Option( ">= " + strs.stat_pop_gte, ">=" );
  505.                     obj.options[5] = new sFrame.Option( "= " + strs.stat_pop_equ, "=" );
  506.                     obj.options[6] = new sFrame.Option( "... " + strs.stat_pop_range, "..." );
  507.                     obj.options[7] = new sFrame.Option( "! " + strs.stat_pop_dups, "!" );
  508.                     obj.options[8] = new sFrame.Option( "// " + strs.stat_pop_today, "//" );
  509.                     obj.options[9] = new sFrame.Option( "? " + strs.stat_pop_inval, "?" );
  510.                     obj.options[10] = new sFrame.Option( "@ " + strs.stat_pop_one, "@" );
  511.                     obj.options[11] = new sFrame.Option( "* " + strs.stat_pop_zero, "*" );
  512.                     obj.options[12] = new sFrame.Option( '"" ' + strs.stat_pop_liter, '""' );
  513.                     obj.options[13] = new sFrame.Option( "~ " + strs.stat_pop_relax, "~" );
  514.                     obj.options[14] = new sFrame.Option( "== " + strs.stat_pop_cont, "==" );
  515.                     obj.options[0].selected = true;
  516.                 }
  517.                 
  518.                 this.setImgButtonState( s, "homeButton", "home" + ( this.isEnglish ? "" : "2" ), true );
  519.                 this.setImgButtonState( s, "browseButton", "browse" + ( this.isEnglish ? "" : "2" ), true );
  520.                 this.setImgButtonState( s, "findButton", "find" + ( this.isEnglish ? "" : "2" ), true );
  521.                 this.updateStatusFrame();
  522.             }
  523.         }
  524.     }
  525.     
  526.     this.setupTopFrame = function( statVis, isEng )
  527.     {
  528.         if( this.strings != null && statVis != null && isEng != null )
  529.         {
  530.             this.statusVisible = statVis;
  531.             this.isEnglish = isEng;
  532.             if( document != null )
  533.                 document.title = this.strings.home_ttl_iwp;
  534.         }
  535.     }
  536.     
  537.     this.updateNavPanel = function( win, info, strs )
  538.     {
  539.         if( win != null && info != null && strs != null )
  540.         {
  541.             var obj = null;
  542.             var doc = win.document;
  543.             if( doc != null )
  544.                 obj = doc.getElementById("laypopup");
  545.             if( obj != null && obj.options != null )
  546.             {
  547.                 var opts = obj.options;
  548.                 var lays = info.layouts;
  549.                 var index = lays[0];
  550.                 opts.length = 0;
  551.                 for( var i = 1; i < lays.length; ++i, ++index )
  552.                 {
  553.                     var opt = new win.Option(lays[i], index );
  554.                     opts[i-1] = opt;
  555.                 }
  556.                 index = 0;
  557.                 if( info.lay > 0 )
  558.                     index = info.lay - lays[0];
  559.                 opts[index].selected = true;
  560.             }
  561.     
  562.             if( doc != null )
  563.                 obj = doc.getElementById("viewpopup");
  564.             if( obj != null && obj.options != null )
  565.             {
  566.                 var opts = obj.options;
  567.                 opts.length = 0;
  568.                 if( info.formviewenabled )
  569.                     opts[opts.length] = new win.Option(strs.stat_pop_form,"form");
  570.                 if( info.listviewenabled )
  571.                     opts[opts.length] = new win.Option(strs.stat_pop_list,"list");
  572.                 if( info.tableviewenabled )
  573.                     opts[opts.length] = new win.Option(strs.stat_pop_table,"table");
  574.     
  575.                 for( var i = 0; i < opts.length; ++i )
  576.                 {
  577.                     var opt = opts[i];
  578.                     if( opt.value == info.viewas )
  579.                     {
  580.                         opt.selected = true;
  581.                         break;
  582.                     }
  583.                 }
  584.             }
  585.             
  586.             if( info.viewas == "form" )
  587.                 this.setObjVisibility( doc, "rangeBox", false );
  588.             else
  589.             {
  590.                 var rangemax;
  591.                 var end = info.recnum + info.pagesize - 1;
  592.                 if( info.mode == this.findMode )
  593.                     rangemax = info.total;
  594.                 else
  595.                     rangemax = info.found;
  596.                 if( end > rangemax )
  597.                     end = rangemax;
  598.                 this.addOrReplaceTextNode( doc, "rangeLeft", info.recnum, 0 );
  599.                 this.addOrReplaceTextNode( doc, "rangeRight", end, 0 );
  600.                 this.setObjVisibility( doc, "rangeBox", true );
  601.             }
  602.         }
  603.     }
  604.     
  605.     this.setToobarState = function( doc, info, disable )
  606.     {
  607.         if( doc != null && info != null && disable  != null )
  608.         {
  609.             if( info.cannew )
  610.                 this.setImgButtonState( doc, "newButton", "new", disable );
  611.             else
  612.                 this.setImgButtonState( doc, "newButton", "new", true );
  613.             if( info.canedit && info.recnum > 0 )
  614.                 this.setImgButtonState( doc, "editButton", "edit", disable );
  615.             else
  616.                 this.setImgButtonState( doc, "editButton", "edit", true );
  617.             this.setImgButtonState( doc, "noeditButton", "noedit", disable );
  618.             if( info.cannew && info.recnum > 0 )
  619.                 this.setImgButtonState( doc, "dupButton", "dup", disable );
  620.             else
  621.                 this.setImgButtonState( doc, "dupButton", "dup", true );
  622.             if( info.candelete && info.recnum > 0 )
  623.                 this.setImgButtonState( doc, "deleteButton", "delete", disable );
  624.             else
  625.                 this.setImgButtonState( doc, "deleteButton", "delete", true );
  626.             this.setImgButtonState( doc, "sortButton", "sort", disable || info.found == 0 );
  627.             this.setImgButtonState( doc, "showallButton", "showall", disable || info.total == 0 );
  628.             this.setObjVisibility( doc, "downBox", ! disable && info.recnum > 0 );
  629.         }
  630.     }
  631.     
  632.     this.updateStatusFrame = function( win )
  633.     {
  634.         if( win != null )
  635.             this.bodyFrame = win;
  636.         var bFrame = this.bodyFrame;
  637.         if( bFrame != null && bFrame.iwpinfo != null )
  638.         {
  639.             var info = bFrame.iwpinfo;
  640.             if( this.statusVisible != info.visible )
  641.             {
  642.                 var url = this.cgiPath()
  643.                 if( url != null )
  644.                 {
  645.                     url += "-db=" + info.db.url + "&-loadframes";
  646.                     window.location = url;
  647.                     return;
  648.                 }
  649.             }
  650.             this.setupControlFrame( this.controlFrame, info );
  651.             this.openUrlWindows( info.urls );
  652.             if( ! this.statusVisible )
  653.                 return;
  654.             var sFrame = this.statusFrame;
  655.             if( sFrame != null && sFrame.document != null && this.strings != null )
  656.             {
  657.                 var s = sFrame.document;
  658.                 var strs = this.strings;
  659.                 this.setObjVisibility( s, "statusBox", true );
  660.                 this.setObjVisibility( s, "moveBox", true );
  661.                 if( info.debug != null )
  662.                     this.setObjVisibility( s, "debugBox", true );
  663.                 if( info.mode == this.findMode )
  664.                 {
  665.                     this.setObjVisibility( s, "resetBox", false );
  666.                     this.setObjVisibility( s, "statusBox", false );
  667.                     this.setObjVisibility( s, "modeBrowseBox", false );
  668.                     this.setObjVisibility( s, "modeEditBox", false );
  669.                     this.setObjVisibility( s, "toolBox", false );
  670.                     this.setObjVisibility( s, "toolBox2", false );
  671.                     this.setObjVisibility( s, "submitPanel", false );
  672.                     this.setObjVisibility( s, "editPanel", false );
  673.                     this.setObjVisibility( s, "browsePanel", false );
  674.                     this.setObjVisibility( s, "prevBox", false );
  675.                     this.setObjVisibility( s, "nextBox", false );
  676.                     this.setObjVisibility( s, "prevMultiBox", false );
  677.                     this.setObjVisibility( s, "nextMultiBox", false );
  678.                     this.setObjVisibility( s, "refindBox", false );
  679.                     this.updateNavPanel( sFrame, info, strs );
  680.                     this.setImgButtonState( s, "homeButton", "home" + ( this.isEnglish ? "" : "2" ), false );
  681.                     this.setImgButtonState( s, "browseButton", "browse" + ( this.isEnglish ? "" : "2" ), false );
  682.                     this.setImgButtonState( s, "findButton", "find" + ( this.isEnglish ? "" : "2" ), true );
  683.                     this.setImgButtonState( s, "resetFindButton", "undo", false );
  684.                     this.setImgButtonState( s, "prevFindButton", "previous", info.recnum <= 1 );
  685.                     this.setImgButtonState( s, "nextFindButton", "next", info.recnum == info.total );
  686.                     this.setImgButtonState( s, "delReqButton", "delreq", info.total <= 1 );
  687.                     this.setValue( s, "reqnumField", info.recnum );
  688.                     var obj = s.getElementById("omitCheckbox");
  689.                     if( obj != null )
  690.                         obj.checked = info.omitstate
  691.                     this.addOrReplaceTextNode( s, "requestsNum", info.total, 0 );
  692.                     var moveBox = s.getElementById( "moveBox" );
  693.                     if( moveBox != null && this.positions.currentTop == null )
  694.                         this.positions.currentTop = moveBox.style.top;
  695.                     this.setTop( s, "moveBox", 71 );
  696.                     this.setTop( s, "buttonPanel", 360 );
  697.                     this.setObjVisibility( s, "statusBox", true );
  698.                     this.setObjVisibility( s, "modeFindBox", true );
  699.                     this.setObjVisibility( s, "findToolBox", true );
  700.                     this.setObjVisibility( s, "navPanel", true );
  701.                     this.setObjVisibility( s, "findPanel", true );
  702.                     this.setObjVisibility( s, "logoutBox", true );
  703.                     this.setObjVisibility( s, "resetFindBox", true );
  704.                     this.setObjVisibility( s, "prevFindBox", true );
  705.                     this.setObjVisibility( s, "nextFindBox", true );
  706.                 }
  707.                 else if( info.mode != this.browseMode && info.confirm )
  708.                 {
  709.                     this.setObjVisibility( s, "resetFindBox", false );
  710.                     this.setObjVisibility( s, "statusBox", false );
  711.                     this.setObjVisibility( s, "modeFindBox", false );
  712.                     this.setObjVisibility( s, "modeBrowseBox", false );
  713.                     this.setObjVisibility( s, "toolBox2", false );
  714.                     this.setObjVisibility( s, "findToolBox", false );
  715.                     this.setObjVisibility( s, "navPanel", false );
  716.                     this.setObjVisibility( s, "findPanel", false );
  717.                     this.setObjVisibility( s, "browsePanel", false );
  718.                     this.setObjVisibility( s, "logoutBox", false );
  719.                     this.setObjVisibility( s, "noeditBox", false );
  720.                     this.setObjVisibility( s, "prevBox", false );
  721.                     this.setObjVisibility( s, "nextBox", false );
  722.                     this.setObjVisibility( s, "prevFindBox", false );
  723.                     this.setObjVisibility( s, "nextFindBox", false );
  724.                     this.setObjVisibility( s, "prevMultiBox", false );
  725.                     this.setObjVisibility( s, "nextMultiBox", false );
  726.                     this.setObjVisibility( s, "refindBox", false );
  727.                     this.setImgButtonState( s, "homeButton", "home" + ( this.isEnglish ? "" : "2" ), true );
  728.                     this.setImgButtonState( s, "browseButton", "browse" + ( this.isEnglish ? "" : "2" ), true );
  729.                     this.setImgButtonState( s, "findButton", "find" + ( this.isEnglish ? "" : "2" ), true );
  730.                     this.addOrReplaceTextNode( s, "eprecordNum", info.recnum, 0 );
  731.                     this.addOrReplaceTextNode( s, "epfoundNum", info.found, 0 );
  732.                     this.addOrReplaceTextNode( s, "eptotalNum", info.total, 0 );
  733.                     var moveBox = s.getElementById( "moveBox" );
  734.                     if( moveBox != null && this.positions.currentTop == null )
  735.                         this.positions.currentTop = moveBox.style.top;
  736.                     this.setTop( s, "moveBox", 71 );
  737.                     this.setTop( s, "buttonPanel", 269 );
  738.                     this.setToobarState( s, info, true );
  739.                     this.setImgButtonState( s, "resetButton", "undo", false );
  740.                     this.setObjVisibility( s, "statusBox", true );
  741.                     this.setObjVisibility( s, "editBox", true );
  742.                     this.setObjVisibility( s, "modeEditBox", true );
  743.                     this.setObjVisibility( s, "toolBox", true );
  744.                     this.setObjVisibility( s, "submitPanel", true );
  745.                     this.setObjVisibility( s, "editPanel", true );
  746.                     this.setObjVisibility( s, "resetButton", true );
  747.                 }
  748.                 else
  749.                 {
  750.                     this.setObjVisibility( s, "resetFindBox", false );
  751.                     this.setObjVisibility( s, "statusBox", false );
  752.                     this.setObjVisibility( s, "modeFindBox", false );
  753.                     this.setObjVisibility( s, "modeEditBox", false );
  754.                     this.setObjVisibility( s, "findToolBox", false );
  755.                     this.setObjVisibility( s, "submitPanel", false );
  756.                     this.setObjVisibility( s, "editPanel", false );
  757.                     this.setObjVisibility( s, "findPanel", false );
  758.                     this.setObjVisibility( s, "prevFindBox", false );
  759.                     this.setObjVisibility( s, "nextFindBox", false );
  760.                     this.updateNavPanel( sFrame, info, strs );
  761.                     this.setValue( s, "recnumField", info.recnum );
  762.                     this.setImgButtonState( s, "homeButton", "home" + ( this.isEnglish ? "" : "2" ), false );
  763.                     this.setImgButtonState( s, "browseButton", "browse" + ( this.isEnglish ? "" : "2" ), true );
  764.                     this.setImgButtonState( s, "findButton", "find" + ( this.isEnglish ? "" : "2" ), info.total == 0 );
  765.                     this.setObjVisibility( s, "refindBox", info.total > 0 );
  766.                     var prev = strs.stat_hlp_prev;
  767.                     var next = strs.stat_hlp_next;
  768.                     var sortState = strs.stat_lbl_unsort;
  769.                     if( info.sorted )
  770.                         sortState = strs.stat_lbl_sort;
  771.                     this.addOrReplaceTextNode( s, "sortStateBox", sortState, 0 );
  772.                     this.addOrReplaceTextNode( s, "totalNum", info.total, 0 );
  773.                     this.addOrReplaceTextNode( s, "foundNum", info.found, 0 );
  774.                     var moveBox = s.getElementById( "moveBox" );
  775.                     if( moveBox != null && this.positions.currentTop != null )
  776.                     {
  777.                         this.setTop( s, "moveBox", this.positions.currentTop  );
  778.                         this.positions.currentTop = null;
  779.                     }
  780.                     this.setTop( s, "buttonPanel", 269 );
  781.                     this.setObjVisibility( s, "statusBox", true );
  782.                     this.setObjVisibility( s, "modeBrowseBox", true );
  783.                     this.setToobarState( s, info, false );
  784.                     this.setObjVisibility( s, "toolBox", true );
  785.                     var noedit = false;
  786.                     if( info.mode != this.browseMode )
  787.                         noedit = true;
  788.                     this.setObjVisibility( s, "noeditBox", noedit );
  789.                     this.setObjVisibility( s, "editBox", ! noedit );
  790.                     this.setImgButtonState( s, "resetButton", "undo", ! noedit );
  791.                     obj = s.getElementById("toolBox2");
  792.                     if( obj != null )
  793.                     {
  794.                         var vis = this.positions.visible;
  795.                         if(  vis == null )
  796.                             vis =  false;
  797.                         this.setObjVisibility( s, "toolBox2", vis && info.total );
  798.                         this.setObjVisibility( s, "downBox", ! vis && info.total );
  799.                     }
  800.                     this.setObjVisibility( s, "navPanel", true );
  801.                     this.setObjVisibility( s, "browsePanel", true );
  802.                     this.setObjVisibility( s, "logoutBox", true );
  803.                     this.setObjVisibility( s, "resetButton", true );
  804.                     var isForm = ( info.viewas == "form" );
  805.                     this.setObjVisibility( s, "prevBox", isForm );
  806.                     this.setObjVisibility( s, "nextBox", isForm );
  807.                     this.setObjVisibility( s, "prevMultiBox", ! isForm );
  808.                     this.setObjVisibility( s, "nextMultiBox", ! isForm );    
  809.                     if( isForm )
  810.                     {
  811.                         this.setImgButtonState( s, "prevButton", "previous", info.recnum <= 1 );
  812.                         this.setImgButtonState( s, "nextButton", "next", info.recnum == info.found );
  813.                     }
  814.                     else
  815.                     {
  816.                         var min = 5;
  817.                         if( info.viewas == "table" )
  818.                             min = 20;
  819.                         this.setImgButtonState( s, "prevMultiButton", "previous", info.recnum <= 1 );
  820.                         this.setImgButtonState( s, "nextMultiButton", "next", info.found < ( info.recnum + min) );
  821.                     }
  822.             
  823.                 }
  824.                 this.setObjVisibility( s, "scriptBox", info.paused );
  825.                 document.title = info.windowtitle;
  826.             }
  827.         }
  828.     }
  829.  
  830.     /***** event methods *****************************************/
  831.  
  832.     this.focusActiveField = function()
  833.     {
  834.         var bFrame = this.bodyFrame;
  835.         if( bFrame != null && bFrame.document != null && bFrame.document.activeField != null )
  836.         {
  837.             bFrame.document.activeField.focus();
  838.             bFrame.focus();
  839.         }
  840.     }
  841.     
  842.     this.focusFirstField = function()
  843.     {
  844.         var bFrame = this.bodyFrame;
  845.         if( bFrame != null && bFrame.document != null )
  846.         {
  847.             var fld = bFrame.document.getElementById( "active" );
  848.             if( fld != null )
  849.                 fld.focus();
  850.         }
  851.     }
  852.     
  853.     this.handleBlur = function( obj )
  854.     {
  855.     }
  856.  
  857.     this.handleFocus = function( obj )
  858.     {
  859.         if( obj != null )
  860.         {
  861.             var bFrame = this.bodyFrame;
  862.             if( bFrame != null && bFrame.document != null && bFrame.iwpinfo != null )
  863.             {
  864.                 if( bFrame.iwpinfo.mode == this.findMode )
  865.                 {
  866.                     bFrame.document.activeField = obj;
  867.                     var sFrame = this.statusFrame;
  868.                     if( sFrame != null && sFrame.document != null )
  869.                     {
  870.                         var sym = sFrame.document.getElementById( "symbolpopup" );
  871.                         sym.disabled = false;
  872.                     }
  873.                 }
  874.             }
  875.         }
  876.     }
  877.     
  878.     this.handleLoad = function()
  879.     {
  880.         var bFrame = this.bodyFrame
  881.         if( bFrame != null )
  882.         {
  883.             if( ! this.isSafari10 )
  884.                 bFrame.history.forward();
  885.         }
  886.         this.focusFirstField();
  887.     }
  888.         
  889.     this.handleUnload = function()
  890.     {
  891.     }
  892.  
  893.     /***** action methods *****************************************/
  894.     
  895.     this.deleteNow = function()
  896.     {
  897.         var bFrame = this.bodyFrame;
  898.         var path = this.cgiPath();
  899.         if( bFrame != null && bFrame.iwpinfo != null && path != null )
  900.             bFrame.location = path + "-recid=" + bFrame.iwpinfo.currecid + "&-delete";
  901.     }
  902.  
  903.     this.deleteRecord = function( obj )
  904.     {
  905.         if( obj != null && this.objectEnabled( obj ) )
  906.         {
  907.             if( this.strings != null && confirm(this.strings.stat_ask_del) )
  908.                 this.deleteNow();
  909.         }
  910.     }
  911.     
  912.     this.deleteRequest = function( obj )
  913.     {
  914.         if( obj != null && this.objectEnabled( obj ) )
  915.             this.deleteNow();
  916.     }
  917.  
  918.     this.duplicateRecord = function( obj )
  919.     {
  920.         if( obj != null && this.objectEnabled( obj ) )
  921.             this.submitAndContinue( [{target: "-submitclose", n: "-duplicate", v: ""}] );
  922.     }
  923.  
  924.     this.editCancel = function()
  925.     {
  926.         var bFrame = this.bodyFrame;
  927.         var path = this.cgiPath();
  928.         if( bFrame != null && path != null )
  929.             bFrame.location = path + "-canceledit";
  930.     }
  931.     
  932.     this.editRecord = function( obj )
  933.     {
  934.         if( obj != null && this.objectEnabled( obj ) )
  935.             this.submitAndContinue( [{target: "-submitclose", n: "-edit", v: ""}] );
  936.     }
  937.     
  938.     this.editRecById = function( recordID, activeobject, field, repetition, portalrow )
  939.     {
  940.         var bf = this.bodyFrame;
  941.         if(    recordID != null
  942.             && recordID > 0
  943.             && activeobject != null
  944.             && bf != null
  945.             && bf.iwpinfo != null
  946.             && ( ! bf.iwpinfo.confirm || ( bf.iwpinfo.mode == this.findMode || bf.iwpinfo.mode == this.browseMode ) ) )
  947.         {
  948.             var args = new Array();
  949.             if( bf.iwpinfo.mode == this.browseMode && field != null && field.hasChildNodes() )
  950.             {
  951.                 var nodes = field.childNodes;
  952.                 if( nodes.length )
  953.                 {
  954.                     var isCheck = false;
  955.                     for( var i = 0; i < nodes.length; ++i )
  956.                     {
  957.                         var type = nodes[i].type;
  958.                         if( type == "checkbox" )
  959.                             isCheck = true;
  960.                         if( ( ( type == "radio" ) || ( type == "checkbox" ) ) && nodes[i].checked )
  961.                             args[args.length] = {target: null, n: nodes[i].name, v: nodes[i].value};
  962.                     }
  963.                     if( isCheck )
  964.                         args[args.length] = {target: null, n: nodes[0].name, v: ""};
  965.                 }
  966.             }
  967.             
  968.         //    add the repetition number
  969.             args[args.length] = {target: null, n: "-repetition", v: repetition};
  970.         
  971.         //    add the portal row
  972.             args[args.length] = {target: null, n: "-portalrow", v: portalrow};
  973.                     
  974.             this.submitAndContinue( args.concat( [{target: "-type", n: "-recid", v: recordID},
  975.                 {target: "-omitstate", n: "-index", v: activeobject},
  976.                 {target: "-submitclose", n: "-editrecbyid", v: ""}] ) );
  977.         }
  978.     }
  979.  
  980.     this.editSubmit = function( obj, overRide )
  981.     {
  982.         if( obj != null )
  983.         {
  984.             if( overRide == null )
  985.                 overRide = false;
  986.             bFrame = this.bodyFrame;
  987.             if( bFrame != null && bFrame.iwpinfo != null )
  988.             {
  989.                 if( ! bFrame.iwpinfo.confirm || ( overRide || this.objectEnabled( obj ) ) )
  990.                     this.submitAndContinue();
  991.             }
  992.         }
  993.     }
  994.  
  995.     this.findOmitted = function()
  996.     {
  997.         this.submitAndContinue( [{target: "-submitclose", n: "-findomitted", v: ""}] );
  998.     }
  999.     
  1000.     this.insertSymbol = function( obj )
  1001.     {
  1002.         var bFrame = this.bodyFrame;
  1003.         if( obj != null && bFrame != null && bFrame.document != null )
  1004.         {
  1005.             var fld = bFrame.document.activeField;
  1006.             if( fld != null )
  1007.             {
  1008.                 var sel = obj.selectedIndex;
  1009.                 obj.selectedIndex = 0;
  1010.                 if( sel > 0 && sel < obj.options.length )
  1011.                 {
  1012.                     var sym = obj.options[sel].value;
  1013.                     fld.value = fld.value + sym;
  1014.                 }
  1015.             }
  1016.         }
  1017.     }
  1018.  
  1019.     this.logOut = function( target )
  1020.     {
  1021.         this.submitAndContinue( [{target: "-submitclose", n: "-close", v: ""}], "_top" );
  1022.     }
  1023.     
  1024.     this.newRecord = function( obj )
  1025.     {
  1026.         if( obj != null && this.objectEnabled( obj ) )
  1027.             this.submitFindRequest( [{target: "-submitclose", n: "-new", v: ""}] );
  1028.     }
  1029.     
  1030.     this.omitMultiple = function( def )
  1031.     {
  1032.         var strs = this.strings;
  1033.         if( strs != null )
  1034.         {
  1035.             if( def == null )
  1036.                 def = "1";
  1037.             var num = prompt( strs.stat_ask_omit, def );
  1038.             if( ! isNaN(num) && num > 0 )
  1039.                 this.submitAndContinue( [{target: "-omitstate", n: "-count", v: num},{target: "-submitclose", n: "-omitmultiple", v: ""}] );
  1040.             else if( num != null )
  1041.             {
  1042.                 alert(strs.stat_err_omit);
  1043.                 this.omitMultiple( num );
  1044.             }
  1045.         }
  1046.     }
  1047.     
  1048.     this.omitSingle = function()
  1049.     {
  1050.         this.submitFindRequest( [{target: "-submitclose", n: "-omit", v: ""}] );
  1051.     }
  1052.     
  1053.     this.performFind = function( type )
  1054.     {
  1055.         var args = new Array();
  1056.         if( type != null && type > 0 )
  1057.         {
  1058.             var val = "extend";
  1059.             if( type > 1 )
  1060.                 val = "constrain";
  1061.             args[0] = {target: "-type", n: "-type", v: val};
  1062.         }
  1063.         this.submitFindRequest( args );
  1064.     }
  1065.     
  1066.     this.resetForm = function( obj )
  1067.     {
  1068.         if( obj != null && this.objectEnabled( obj ) )
  1069.         {
  1070.             var bFrame = this.bodyFrame;
  1071.             if( bFrame != null && bFrame.document != null )
  1072.             {
  1073.                 var frm = bFrame.document.getElementById( "iwpform" );
  1074.                 if( frm != null )
  1075.                 {
  1076.                     frm.reset();
  1077.                 }
  1078.             }
  1079.         }
  1080.     }
  1081.     
  1082.     this.scriptCancel = function()
  1083.     {
  1084.         this.submitFindRequest( [{target: "-submitclose", n: "-exitscript", v: ""}] );
  1085.     }
  1086.     
  1087.     this.scriptContinue = function()
  1088.     {
  1089.         this.submitFindRequest( [{target: "-submitclose", n: "-resumescript", v: ""}] );
  1090.     }
  1091.     
  1092.     this.showAllRecords = function( obj )
  1093.     {
  1094.         if( obj != null && this.objectEnabled( obj ) )
  1095.             this.submitFindRequest( [{target: "-submitclose", n: "-showall", v: ""}] );
  1096.     }
  1097.     
  1098.     this.sortTableByFieldName = function( index )
  1099.     {
  1100.         var bf = this.bodyFrame;
  1101.         if( index != null && bf != null && bf.iwpinfo != null )
  1102.         {
  1103.             var info = bf.iwpinfo;
  1104.             if( ! info.confirm || ( info.mode == this.findMode || info.mode == this.browseMode ) )
  1105.             {
  1106.                 var order = "ascend";
  1107.                 if( info.sorted && index == info.currentorder.index && info.currentorder.order == order )
  1108.                     order = "descend";
  1109.                 this.submitFindRequest( [{target: "-type", n: "-sortfield.1", v: index},{target: "-omitstate", n: "-sortorder.1", v: order},{target: "-submitclose", n: "-iwpsort", v: ""}] );
  1110.             }
  1111.         }
  1112.     }
  1113.  
  1114.     /***** navigation methods *****************************************/
  1115.  
  1116.     this.goHome = function( obj )
  1117.     {
  1118.         if( obj != null && this.objectEnabled( obj ) )
  1119.             this.submitAndContinue( [{target: "-submitclose", n: "-home", v: ""}], "_top" );
  1120.     }
  1121.     
  1122.     this.goToBrowse = function( obj )
  1123.     {
  1124.         if( obj != null && this.objectEnabled( obj ) )
  1125.             this.submitAndContinue( [{target: "-submitclose", n: "-browse", v: ""}] );
  1126.     }
  1127.     
  1128.     this.goToFind = function( obj )
  1129.     {
  1130.         if( obj != null && this.objectEnabled( obj ) )
  1131.             this.submitAndContinue( [{target: "-submitclose", n: "-find", v: ""}] );
  1132.     }
  1133.  
  1134.     this.goToLayout = function( sel )
  1135.     {
  1136.         if( sel != null && sel.options != null )
  1137.         {
  1138.             var layID = sel.options[sel.selectedIndex].value;
  1139.             this.submitAndContinue( [{target: "-type", n: "-lay", v: layID},{target: "-submitclose", n: "-gotolayout", v: ""}] );
  1140.         }
  1141.     }
  1142.         
  1143.     this.goToNext = function( obj )
  1144.     {
  1145.         if( obj != null && this.objectEnabled( obj ) )
  1146.             this.submitAndContinue( [{target: "-submitclose", n: "-next", v: ""}] );
  1147.     }
  1148.  
  1149.     this.goToPrevious = function( obj )
  1150.     {
  1151.         if( obj != null && this.objectEnabled( obj ) )
  1152.             this.submitAndContinue( [{target: "-submitclose", n: "-prev", v: ""}] );
  1153.     }
  1154.     
  1155.     this.goToRecById = function( recordID )
  1156.     {
  1157.         var bf = this.bodyFrame;
  1158.         if( recordID != null && bf != null && bf.iwpinfo != null && ( ! bf.iwpinfo.confirm || ( bf.iwpinfo.mode == this.findMode || bf.iwpinfo.mode == this.browseMode ) ) )
  1159.             this.submitAndContinue( [{target: "-omitstate", n: "-recid", v: recordID},{target: "-submitclose", n: "-gotorecbyid", v: ""}] );
  1160.     }
  1161.  
  1162.     this.goToRecordNumber = function( objID )
  1163.     {
  1164.         var bFrame = this.bodyFrame;
  1165.         var sFrame = this.statusFrame;
  1166.         if( objID != null && bFrame != null && bFrame.iwpinfo != null && sFrame != null )
  1167.         {
  1168.             var obj = sFrame.document.getElementById(objID);
  1169.             if( obj != null )
  1170.             {
  1171.                 var recNum = obj.value;
  1172.                 if( isNaN(recNum) || recNum < 1 )
  1173.                 {
  1174.                     obj.value = bFrame.iwpinfo.recnum;
  1175.                     return;
  1176.                 }
  1177.                 else if( bFrame.iwpinfo.found < recNum )
  1178.                     recNum = bFrame.iwpinfo.found;
  1179.                 this.submitAndContinue( [{target: "-omitstate", n: "-recordnumber", v: recNum},{target: "-submitclose", n: "-goto", v: ""}] );
  1180.             }
  1181.         }
  1182.     }
  1183.  
  1184.     this.goToRefind = function()
  1185.     {
  1186.         this.submitAndContinue( [{target: "-submitclose", n: "-refind", v: ""}] );
  1187.     }
  1188.     
  1189.     this.goToView = function( sel )
  1190.     {
  1191.         if( sel != null && sel.selectedIndex != null )
  1192.         {
  1193.             var i = sel.selectedIndex;
  1194.             if( i != -1 )
  1195.             {
  1196.                 var view = sel.options[i].value;
  1197.                 var action = "-formview";
  1198.                 if( view == "list" )
  1199.                     action = "-listview";
  1200.                 else if( view == "table" )
  1201.                     action = "-tableview";
  1202.                 this.submitAndContinue( [{target: "-submitclose", n: action, v: ""}] );
  1203.             }
  1204.         }
  1205.     }
  1206.     
  1207.     this.openHelpWindow = function( anchor )
  1208.     {
  1209.         if( anchor == null )
  1210.         {
  1211.             anchor = "Table_of_contents";
  1212.             var bFrame = this.bodyFrame;
  1213.             if( bFrame != null && bFrame.iwpinfo != null )
  1214.             {
  1215.                 var info = bFrame.iwpinfo;
  1216.                 if( info.mode == this.browseMode )
  1217.                     anchor = "Navigating_records";
  1218.                 else if( info.mode == this.editMode )
  1219.                     anchor = "Editing_records";
  1220.                 else if( info.mode == this.newMode )
  1221.                     anchor = "Adding_data";
  1222.                 else if( info.mode == this.findMode )
  1223.                     anchor = "Finding_records";
  1224.             }
  1225.         }
  1226.         var win = window.open("/fmi/iwp/cgi?-gethelp&-anchor=" + anchor,"IWPHelp","top=20,left=20,height=460,width=620,fullscreen=no,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no");
  1227.     }
  1228.     
  1229.     this.openSortDlog = function( obj )
  1230.     {
  1231.         if( obj != null && this.objectEnabled( obj ) )
  1232.         {
  1233.             this.editSubmit();
  1234.             var url = this.cgiPath();
  1235.             if( url != null )
  1236.             {
  1237.                 url += "-opensort";
  1238.                 var win = window.open(url,"iwp_sort","alwaysraised=yes,dependent=yes,top=20,left=20,height=265,width=512,location=no,menubar=no,directories=no,resizable=no,scrollbars=no,status=no,toolbar=no,titlebar=no");
  1239.             }
  1240.         }
  1241.     }
  1242.                 
  1243.     this.openInNewWindow = function( url )
  1244.     {
  1245.         if( url != null )
  1246.         {
  1247.             var winName = "iwp_" + this.winCounter++;
  1248.             var win = window.open(url,winName,"alwaysraised=yes,dependent=yes,top=20,left=20,height=265,width=512,location=no,menubar=no,directories=no,resizable=no,scrollbars=no,status=no,toolbar=no,titlebar=no");
  1249.         }
  1250.     }
  1251.  
  1252.     // gloabals
  1253.     this.isSafari10        =    this.checkForSafari10();
  1254.     this.browseMode        =    "browse";
  1255.     this.editMode        =    "edit";
  1256.     this.newMode        =    "new";
  1257.     this.findMode        =    "find";
  1258.     this.statusVisible    =    false;
  1259.     this.imgPath        =    "/fmi/iwp/res/images/";
  1260.     this.objstate        =    new Object();
  1261.     this.positions        =    new Object();
  1262.     this.debugurl        =    false;
  1263.     this.winCounter        =    0;
  1264. }
  1265.  
  1266. // Create Objects
  1267.  
  1268. if ( window.iwp == null )
  1269.     window.iwp = new IWPObj();
  1270.